package com.aaa.mq;

import com.aaa.config.RabbitMQConfig;
import com.aaa.entity.CReport;
import com.aaa.service.CreportService;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

@Component
public class BillMessageReceiver {

    @Autowired
    private CreportService creportService;

    /**
     * 处理添加和修改操作
     *
     * @param cReport 参数对象
     */
    @Transactional
    @RabbitListener(queues = RabbitMQConfig.QUEUE_SAVE_UPDATE)
    public void receiveBillSaveUpdateMessage(CReport cReport) {
        System.out.println(RabbitMQConfig.QUEUE_SAVE_UPDATE + " 队列获取到数据：" + cReport);
        if (cReport == null) {
            return;
        }
        creportService.addre(cReport);
        System.err.println("消费完成");
    }


}
